<html>
<head>
<title>Group.java</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #cf8e6d;}
.s1 { color: #bcbec4;}
.s2 { color: #bcbec4;}
</style>
</head>
<body bgcolor="#1e1f22">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
Group.java</font>
</center></td></tr></table>
<pre><span class="s0">package </span><span class="s1">school</span><span class="s2">;</span>

<span class="s0">import </span><span class="s1">java</span><span class="s2">.</span><span class="s1">util</span><span class="s2">.</span><span class="s1">ArrayList</span><span class="s2">;</span>
<span class="s0">import </span><span class="s1">java</span><span class="s2">.</span><span class="s1">util</span><span class="s2">.</span><span class="s1">Random</span><span class="s2">;</span>

<span class="s0">public class </span><span class="s1">Group </span><span class="s2">{</span>
    <span class="s0">private </span><span class="s1">ArrayList</span><span class="s2">&lt;</span><span class="s1">Student</span><span class="s2">&gt;</span><span class="s1">Students</span><span class="s2">;</span>
    <span class="s0">private int </span><span class="s1">groupId</span><span class="s2">;</span>
    <span class="s0">public </span><span class="s1">Group</span><span class="s2">(</span><span class="s0">int </span><span class="s1">groupId</span><span class="s2">){</span>
        <span class="s0">this</span><span class="s2">.</span><span class="s1">groupId </span><span class="s2">= </span><span class="s1">groupId</span><span class="s2">;</span>
        <span class="s1">Students </span><span class="s2">= </span><span class="s0">new </span><span class="s1">ArrayList</span><span class="s2">&lt;&gt;();</span>
    <span class="s2">}</span>
    <span class="s0">public int </span><span class="s1">getGroupId</span><span class="s2">(){</span>
        <span class="s0">return  </span><span class="s1">groupId</span><span class="s2">;</span>
    <span class="s2">}</span>
    <span class="s0">public void </span><span class="s1">addstudent</span><span class="s2">(</span><span class="s1">Student student</span><span class="s2">){</span>
        <span class="s1">Students</span><span class="s2">.</span><span class="s1">add</span><span class="s2">(</span><span class="s1">student</span><span class="s2">);</span>
    <span class="s2">}</span>
    <span class="s0">public </span><span class="s1">Student getRandomStudent</span><span class="s2">() {</span>
        <span class="s0">if </span><span class="s2">(</span><span class="s1">Students</span><span class="s2">.</span><span class="s1">isEmpty</span><span class="s2">())</span>
            <span class="s0">return null</span><span class="s2">;</span>
        <span class="s1">Random random </span><span class="s2">= </span><span class="s0">new </span><span class="s1">Random</span><span class="s2">();</span>
        <span class="s0">return </span><span class="s1">Students</span><span class="s2">.</span><span class="s1">get</span><span class="s2">(</span><span class="s1">random</span><span class="s2">.</span><span class="s1">nextInt</span><span class="s2">(</span><span class="s1">Students</span><span class="s2">.</span><span class="s1">size</span><span class="s2">()));</span>
    <span class="s2">}</span>
    <span class="s0">public int </span><span class="s1">GetGroup</span><span class="s2">(){</span>
        <span class="s0">return </span><span class="s1">groupId</span><span class="s2">;</span>
    <span class="s2">}</span>
<span class="s2">}</span>
</pre>
</body>
</html>